function deepClone(source) {
  // 判断复制的目标是数组还是对象
  const targetObj = source.constructor === Array ? [] : {}
  for (let keys in source) {
    //如果值是对象,就递归一下
    if (source[keys] && typeof source[keys] === 'object') {
      // 判断复制的目标是数组还是对象
      targetObj[keys] = source[keys].constructor === Array ? [] : {}
      targetObj[keys] = deepClone(source[keys])
    } else {
      // 如果不是,直接赋值
      targetObj[keys] = source[keys]
    }
  }
  return targetObj
}
const obj = { name: '夏', age: 27, wife: { name: '周', age: 26 } }
const obj2 = deepClone(obj)
obj2.wife.age = 11
console.log(obj)
console.log(obj2)
